import defaultEnv from '../../env'

export default {
  getParams: () => {
    let env = defaultEnv;
    let defApi = env.CRM_API_HOST
    let location = document.location
    let params = new URLSearchParams(location.search.substring(1));
    if (params.get('api')) {
      env.CRM_API_HOST = params.get('api')
      console.log('host', env.CRM_API_HOST)
    } else if (params.get('strict')) {
      env.CRM_API_HOST = location.origin
      console.log('strict', env.CRM_API_HOST)
    }
    env.RELEASE_API_HOST = env.RELEASE_API_HOST.replace(defApi, env.CRM_API_HOST)
    env.TAG_API_HOST = env.TAG_API_HOST.replace(defApi, env.CRM_API_HOST)
    env.CORP_API_HOST = env.CORP_API_HOST.replace(defApi, env.CRM_API_HOST)
    env.MSG_API_HOST = env.MSG_API_HOST.replace(defApi, env.CRM_API_HOST)

    return env
  }
}